﻿global using static System.String;

using System.Linq;
using ICSharpCode.Decompiler;
using il2lua;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Rocks;
using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.CSharp.Syntax;
using System.IO;
using ICSharpCode.Decompiler.Util;
const string path = "IL2LuaTest.dll";
var settings = new DecompilerSettings();
settings.UsingDeclarations = false;
settings.SwitchStatementOnString = false;
settings.AutomaticEvents = false;
settings.AggressiveInlining = true;
settings.UseEnhancedUsing = false;
var decompiler = new CSharpDecompiler(path, settings);
var type = decompiler.TypeSystem.MainModule.TypeDefinitions.Where(x => x.Name == "Module").FirstOrDefault();
var writer = new CodeWriter(Console.Out);
var context = new Context();
foreach (var method in type.Methods)
{
    if (!method.HasBody)
        continue;
    context.CurrentMethod = method;
    var methodGenerator = new MethodGenerator(writer,method,decompiler);
    methodGenerator.Generate(context);
}